package org.czl.leetcode4;
import java.util.HashMap;

public class l {
    public static void main(String[] args) {
        System.out.println(lengthAfterTransformations("abcyy", 26));
    }

    public static int lengthAfterTransformations(String s, int t) {
        int MOD = 1000000007;
        int ans = 0;
        HashMap<Character, Integer> map = new HashMap<>();
        for(int i = 0; i < 26; i++){
            int ret = f('a' ,  t);
            map.put((char) ('a' + i), ret);
        }
        for(char c : s.toCharArray()){
            int temp = map.get(c);
            ans += temp % MOD;
        }
        return ans;
    }
   static int f(char c, int t){
        StringBuilder str1 = new StringBuilder();
        str1.append(c);
        StringBuilder str2 = new StringBuilder();
        for(int i = 0; i < t; i++){
            for(int j  = 0; j < str1.length(); j++){
                if(str1.charAt(j) == 'z'){
                    str2.append('a');
                    str2.append('b');
                }else{
                    str2.append((char) (str1.charAt(j) + 1));
                }
            }
            str1.setLength(0);
            str1 = new StringBuilder(str2);
            str2.setLength(0);
        }
        return str1.length();
    }
}
